<!DOCTYPE html>
<html ng-app='app'>

<head>
  <meta charset="utf-8">
  <title translate="TITLE">Set a storage key</title>
  <style>body { text-align: center; }</style>
</head>

<body ng-controller="ctrl">

  <p>
    <a href="#" ng-click="setLang('en_US')">English</a>
    |
    <a href="#" ng-click="setLang('ru_RU')">Русский</a>
  </p>

  <h1 translate>HEADER</h1>
  <h2 translate>SUBHEADER</h2>

<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-cookies/angular-cookies.js"></script>
<script src="../dist/angular-translate.js"></script>
<script src="../dist/angular-translate-storage-cookie/angular-translate-storage-cookie.js"></script>

<script>
angular.module('app', ['pascalprecht.translate', 'ngCookies'])

.config(['$translateProvider', function($translateProvider){

  // Adding a translation table for the English language
  $translateProvider.translations('en_US', {
    "TITLE"     : "How to remember a language (local storage)",
    "HEADER"    : "Your application is able to remember a language between requests.",
    "SUBHEADER" : "And you is able to set a prefix for the default storage key."
  });

  // Adding a translation table for the Russian language
  $translateProvider.translations('ru_RU', {
    "TITLE"     : "Как запомнить язык (local storage)",
    "HEADER"    : "Ваше приложение может запоминать язык между запросами.",
    "SUBHEADER" : "И Вы сожете установить префикс для ключа по умолчанию.",
  });

  // Tell the module what language to use by default
  $translateProvider.preferredLanguage('en_US');

  // Tell the module to store the language in the cookies
  $translateProvider.useCookieStorage();

  // Tell the module to use a prefix 'myCoolApp' for the default storage key
  $translateProvider.storagePrefix('myCoolApp');

}])

.controller('ctrl', ['$scope', '$translate', function($scope, $translate) {

  $scope.setLang = function(langKey) {
    // You can change the language during runtime
    $translate.use(langKey);
  };

}]);
</script>

</body>
</html>
